<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
  <link rel="stylesheet" href="//at.alicdn.com/t/c/font_3854199_8o3d86xbw3x.css" />
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      background-color: rgb(187, 4, 187);
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }

    li {
      list-style: none;
    }

    ul {
      display: flex;
      gap: 30px;
      /* flex-direction: column; */
      color: #fff;
    }

    li {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      gap: 10px;
    }

    .num {
      font-size: 40px;
    }

    .iconfont {
      font-size: 40px;
    }
  </style>
</head>

<body>
  <ul>
    <li>
      <span class="iconfont icon-weibo"></span>
      <span class="num" data-target="1285">0</span>
      <span>微博粉丝数量</span>
    </li>
    <li>
      <span class="iconfont icon-bilibili-fill"></span>
      <span class="num" data-target="1680">0</span>
      <span>微博粉丝数量</span>
    </li>
    <li>
      <span class="iconfont icon-douyin"></span>
      <span class="num" data-target="12345">0</span>
      <span>微博粉丝数量</span>
    </li>
  </ul>
</body>
<script>
  let nums = document.querySelectorAll('.num');
  nums.forEach((item) => {
    let targetNum = item.getAttribute('data-target');
    let increase = parseInt(targetNum / 50);
    let i = 0;

    const fn = () => {
      i += increase;
      item.textContent = i;
      if (i < targetNum) { //如果当前增长量没有超过粉丝量
        window.requestAnimationFrame(fn);
      } else { //有可能会超过粉丝量 超过之后重新赋值一下
        item.textContent = targetNum;
      }
    }
    // window.requestAnimationFrame() 接收一个回调函数，浏览器在下次重新绘制页面之前会调用此方法
    window.requestAnimationFrame(fn);
  });
</script>

</html>